package com.adingxiong.cft.common.entity;

import lombok.Data;

import java.awt.image.BufferedImage;
import java.time.LocalDateTime;

/**
 * @ClassName ImageCode
 * @Description TODO
 * @Author xiongchao
 * @Date 2020/10/15 11:29
 **/
@Data
public class ImageCode {

    private BufferedImage image;

    private String code ;

    /**
     失效时间
     */
    private LocalDateTime expireTime;

    public ImageCode(BufferedImage image,String code,LocalDateTime expireTime){
        this.image = image;
        this.code = code;
        this.expireTime = expireTime;
    }

    public ImageCode(BufferedImage image,String code ,int expireTime){
        this.image = image;
        this.code = code;
        LocalDateTime localDateTime = LocalDateTime.now().plusSeconds(expireTime);
        this.expireTime = localDateTime;
    }

    public boolean isExpire(){
        return LocalDateTime.now().isAfter(expireTime);
    }


}
